﻿using System;
using Landpy.CruiseControlNet.ConfigurationSidekick.ConfigTreeModule;

namespace Landpy.CruiseControlNet.ConfigurationSidekick.ConfigPropertyModule
{
    class InternalSecurityUserHandler : GetPropertiesHandler
    {
        public override object GetPropertiesObject(GetPropertiesContext getPropertiesContext)
        {
            var treeNodeIndentity = this.GetTreeNodeIndentity(getPropertiesContext);
            if ((treeNodeIndentity.Type & TreeNodeType.InternalSecurityUser) != TreeNodeType.Unknow)
            {
                var querySecurityUser =
                    this.SecurityUserRepository.GetInternalSecurityUserById(
                        getPropertiesContext.CruiseControl.InternalSecurity, new Guid(treeNodeIndentity.Key));
                return querySecurityUser;
            }
            return this.Successor.GetPropertiesObject(getPropertiesContext);
        }
    }
}
